<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
      <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
    <link rel="stylesheet" href="style.css">
    <title></title>
  </head>
  <body class="middle">
    <div class="wrap">
      <div class="content-wrap middle">
        <p class="middle">I am content</br>@VincentTV</p>
      </div>
      <div class="like-wrap middle">
        <i class="fas fa-heart">
          <span>like</span>
        </i>
      </div>
    </div>
  </body>
  <script type="text/javascript">
    (function(w, d) {
      d.querySelector('.like-wrap').addEventListener('click', (e) => {
        d.querySelector('.like-wrap').classList.toggle('like-active')
        addLike(e);
      });
      let likeArr = [];
      function addLike(e) {
        var likeDiv = d.createElement('div')
        likeDiv.classList.add('like')
        likeDiv.innerHTML = '<i class="fas fa-heart"></i>';
        d.body.appendChild(likeDiv)
        likeArr.push({
          el: likeDiv,
          top: e.clientY - 20,
          left: e.clientX - 10,
          opacity: 1,
          scale: 1,
          color: `rgb(${255*Math.random()}, ${255*Math.random()}, ${255*Math.random()})`
        });
        moveLike();
      };

      function moveLike() {
        for(let i = 0; i<likeArr.length; i++) {
          if (likeArr[i].opacity <= 0) {
            d.body.removeChild(likeArr[i].el)
            likeArr.splice(i, 1);
            return;
          }
          likeArr[i].top--;
          likeArr[i].opacity -= 0.01;
          likeArr[i].scale += 0.01;
          likeArr[i].el.style.cssText = `
            top:${likeArr[i].top}px;
            left:${likeArr[i].left}px;
            color:${likeArr[i].color};
            opacity:${likeArr[i].opacity};
            transform:scale(${likeArr[i].opacity});
          `;
        }
        w.requestAnimationFrame(moveLike);
      }

    })(window, document)

  </script>
</html>
